package com.aw.baselib.util

import android.app.Activity

/**
 * Created by hzw
 */
object ReLoginUtil {
    fun reLogin(activity: Activity?, needFinish: Boolean) {
        clearLocalLoginInfo()
        //        activity.startActivity(new Intent(activity, LoginActivity.class));
//        if(needFinish) {
//            activity.finish();
//        }
    }

    fun reLoginFromApplication() {
        clearLocalLoginInfo()
        //        for(Activity activity : AwActivityCollectorUtil.activitys) {
//            if(!(activity instanceof MainActivity)) {
//                activity.finish();
//            }
//        }
//        EventBus.getDefault().postSticky(new RxMainSwitchTabType(RxMainSwitchTabType.TAB_INDEX));
//        Intent intent = new Intent(MyApp.getInstance(), LoginActivity.class);
//        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//        MyApp.getInstance().startActivity(intent);
    }

    fun clearLocalLoginInfo() {
        UserUtil.clearUser()
        //        TIMManager.getInstance().logout(new TIMCallBack() {
//            @Override
//            public void onError(int i, String s) {
//                AwLog.d("IM 退出登录 fail, " + s +  " ,i: " + i);
//            }
//
//            @Override
//            public void onSuccess() {
//                AwLog.d("IM 退出登录 success");
//            }
//        });
    }
}